﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Revis.VClinicNet.Core.Domain;

namespace Revis.VClinicNet.Core.Domain.Credentials
{
    public class PatientUser
    {
        public virtual long Id { get; protected set; }
        public virtual string Password { get; protected set; }
        public virtual bool IsActive { get; protected set; }
        public virtual Patient Related { get; protected set; }

        #region Constructors

        public PatientUser()
        {
        }

        public PatientUser(string password, Patient related) :
            this(0, password, related)
        {

        }

        public PatientUser(long id, string password, Patient related)
        {
            SetUpFields(password);
            Id = id;
            IsActive = false;
            if (related == null) {
                throw new ArgumentNullException("Null related worker");
            }
            Related = related;
        }

        #endregion

        #region Public Methods

        public virtual void Change(string hashedPassword)
        {
            SetUpFields(hashedPassword);
        }

        public virtual void SetPassword(string newPassword)
        {
            Password = newPassword;
        }

        public virtual void SetActive()
        {
            IsActive = true;
        }

        public virtual void SetInactive()
        {
            IsActive = false;
        }

        #endregion

        #region Private Methods

        private void SetUpFields(string password)
        {
            if (password == null) {
                throw new ArgumentNullException("Null hashedPassword");
            }

            Password = password;
        }

        #endregion
    }
}
